function hot() {
    $.ajax({
        url:'/admin/hot',
        type: 'get',
        dataType:'json',
        success:function (res) {
            let heatArr=[];
            let songArr=[];
            for (let i=0;i<10;i++){
                heatArr[i]=res[i].num;
                songArr[i]=res[i].songName;
            }

            console.log(res);
            $('#box').html(`
                <canvas id="myChart"></canvas>
            `)

            // 数据
            var data = {
                labels: songArr,
                datasets: [{
                    label: '热度',
                    backgroundColor: ['rgb(255, 99, 132, 0.5)', 'rgb(54, 162, 235, 0.5)', 'rgb(255, 206, 86, 0.5)', 'rgb(75, 192, 192, 0.5)', 'rgb(153, 102, 255, 0.5)', 'rgb(255, 159, 64, 0.5)', 'rgb(255, 192, 203, 0.5)', 'rgb(128, 128, 128, 0.5)', 'rgb(135, 206, 235, 0.5)', 'rgb(255, 255, 153, 0.5)'],
                    data: heatArr,
                }]
            };

            // 选项r
            var options = {
                scales: {
                    yAxes: [{
                        ticks: {
                            beginAtZero: true
                        }
                    }]
                }
            };

            // 创建柱状图
            var ctx = document.getElementById('myChart');
            var myChart = new Chart(ctx, {
                type: 'bar',
                data: data,
                options: options
            });
        }
    })
}function soaring() {
    $.ajax({
        url:'/admin/soaring',
        type: 'get',
        dataType:'json',
        success:function (res) {
            let heatArr=[];
            let songArr=[];
            for (let i=0;i<10;i++){
                heatArr[i]=res[i].heat;
                songArr[i]=res[i].songName;
            }

            console.log(res);
            $('#box').html(`
                <button type="button" class="btn btn-dark" onclick="resetSoaring()">重置榜单</button>
                <canvas id="myChart"></canvas>
            `)

            // 数据
            var data = {
                labels: songArr,
                datasets: [{
                    label: '飙升',
                    backgroundColor: ['rgb(255, 99, 132, 0.5)', 'rgb(54, 162, 235, 0.5)', 'rgb(255, 206, 86, 0.5)', 'rgb(75, 192, 192, 0.5)', 'rgb(153, 102, 255, 0.5)', 'rgb(255, 159, 64, 0.5)', 'rgb(255, 192, 203, 0.5)', 'rgb(128, 128, 128, 0.5)', 'rgb(135, 206, 235, 0.5)', 'rgb(255, 255, 153, 0.5)'],
                    data: heatArr,
                }]
            };

            // 选项r
            var options = {
                scales: {
                    yAxes: [{
                        ticks: {
                            beginAtZero: true
                        }
                    }]
                }
            };

            // 创建柱状图
            var ctx = document.getElementById('myChart');
            var myChart = new Chart(ctx, {
                type: 'bar',
                data: data,
                options: options
            });
        }
    })
}
function resetSoaring() {
    if (confirm("确认重置？")){
        $.ajax({
            url:'/admin/resetSoaring',
            type:'get',
            success:function () {
                soaring();
            }
        })
    }
}
